package com.em.controller;

import com.em.service.FeeService;
import com.em.service.PropertyService;
import com.em.service.ResidentService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;

import java.math.BigDecimal;
import java.util.Map;

@Controller
@RequestMapping("/statistics")
public class StatisticsController {

    @Autowired
    private ResidentService residentService;
    @Autowired
    private PropertyService propertyService;
    @Autowired
    private FeeService feeService;
    @GetMapping("/main")
    public String showStatistics(Model model) {
        model.addAttribute("residentCount", residentService.count());
        model.addAttribute("propertyStatusStats", propertyService.getStatusCount());
        model.addAttribute("totalPaid", feeService.getTotalPaid());
        model.addAttribute("totalUnpaid", feeService.getTotalUnpaid());
        model.addAttribute("feeTypeStats", feeService.getFeeTypeStats());
        return "statistics/main";
    }
}
